﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Practices.EnterpriseLibrary.Data;
using Enterprise.DataFactory;
using Enterprise.Model.Permission;
using Enterprise.Infrastructure;
namespace Enterprise.Data.Permission
{
    /// <summary>
    /// 权限按钮表操作
    /// </summary>
    public class PermissionData
    {
        /// <summary>
        ///  权限按钮数据列表
        /// </summary>
        /// <returns></returns>
        public List<PermissionEntity> PermissionList()
        {
            List<PermissionEntity> list = new List<PermissionEntity>();
            string cmd = "Select * from SYS_PERMISSION";
            IDataReader dr = DbExecute.DataReader(cmd);
            while (dr.Read())
            {
                PermissionEntity entity = new PermissionEntity();
                if (!Convert.IsDBNull(dr["PKEY"])) entity.PKEY = Convert.ToInt32(dr["PKEY"]);
                if (!Convert.IsDBNull(dr["PNAME"])) entity.PNAME = Convert.ToString(dr["PNAME"]);
                if (!Convert.IsDBNull(dr["PACTION"])) entity.PACTION = Convert.ToString(dr["PACTION"]);
                list.Add(entity);
            }
            dr.Close();
            return list;
        }

        /// <summary>
        /// 权限按钮数据操作方法
        /// </summary>
        /// <param name="cmd"></param>
        public void PermissionExecute(string cmd)
        {
            DbExecute.Execute(cmd);
        }
    }
}
